<template>
	<scroll-view scroll-y @scrolltolower="handleData" class="vedio">
			<view class="vedioContent">
					<view class="vedioImg" v-for="(item,index) in vedioData"  @click="toVedioDetail(item,index)" :key="index">
						<image :src="item.img" mode="aspectFill"></image>
					</view>
			</view>
	</scroll-view>
</template>

<script>
	export default {
		props:{
			urlobj:Object
		},
		watch:{
			urlobj(){
				this.params = this.urlobj.params
				this.requestUrl = this.urlobj.url
				this.vedioData = []
				console.log(this.urlobj)
				this.getList()
			}
		},
		data() {
			return {
				requestUrl:'http://157.122.54.189:9088/videoimg/v1/videowp/featured',
				params:{
					limit:30,
					skip:0,
					order:'hot'
				},
				vedioData:[],
				havemore:true
			};
		},
		mounted() {
			this.getList()
		},
		methods:{
			getList(){
				this.request({
					url:this.requestUrl,
					data:this.params
				}).then(res =>{
					this.vedioData = [...this.vedioData,...res.data.res.videowp]
					console.log(res.data.res)
					if(res.data.res.videowp.length === 0){
						this.havemore = false
					}
				})
			},
			handleData(){
				if(this.havemore){
					this.params.skip += 30
					this.getList()
				}else{
					uni.showToast({
						title:'没有更多了',
						icon:'none'
					})
					return
				}
			
			},
			toVedioDetail(item,index){
				getApp().globalData.vedioList = this.vedioData
				getApp().globalData.vedio = item
				getApp().globalData.vedioIndex = index
				console.log(index)
				uni.navigateTo({
					url:'/pages/video/videoDetail/index'
				})
				
			}
		}
	}
</script>

<style lang="scss" scoped>
.vedio{
	height: calc(100vh - 36rpx);
	.vedioContent{
		display: flex;
		justify-content: space-around;
		flex-wrap: wrap;
		.vedioImg{
			width: 33.33%;
			height: 400rpx;
			image{
				height: 100%;
				width: 100%;
				border: 10rpx solid #fff;
			}
		}
	}
}
</style>
